home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / movement / Balloon.lua < prev    next >
Text File  |  2009-09-27  |  2KB  |  69 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Balloon
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.balloon={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.balloon.gfx_wpn=loadgfx("weapons/balloon.png")                        -- Weapon Image
  13. setmidhandle(cc.balloon.gfx_wpn)
  14. cc.balloon.sfx_wpn=loadsfx("pop.wav")                                    -- Balloon Pop Sound
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon: balloon
  18. --------------------------------------------------------------------------------
  19.  
  20. cc.balloon.id=addweapon("cc.balloon","Balloon",cc.balloon.gfx_wpn,1)    -- Add Weapon (1 use)
  21.  
  22. function cc.balloon.draw()                                                    -- Draw
  23.     if weapon_mode==1 then
  24.         setblend(blend_alpha)
  25.         setalpha(0.6)
  26.         setcolor(255,255,255)
  27.         setscale(getplayerdirection(0),1)
  28.         setrotation(0)
  29.         drawimage(cc.balloon.gfx_wpn,getplayerx(0),getplayery(0)-33)
  30.         hudinfo("Hit [Space] again to deactivate the balloon!")
  31.     elseif weapon_shots==0 then
  32.         hudinfo("Hit [Space] once to activate the balloon!")
  33.     end
  34. end
  35.  
  36. function cc.balloon.attack(attack)                                        -- Attack
  37.     if weapon_timer>0 then
  38.         weapon_timer=weapon_timer-1
  39.     end
  40.     if (weapon_mode==0) and (weapon_shots==0) and (attack==1) then
  41.         -- Use weapon and allow to use another one afterwards (1)
  42.         useweapon(1)
  43.         -- Activate
  44.         weapon_mode=1
  45.         weapon_shots=1
  46.         weapon_timer=50
  47.         -- Initial Push
  48.         playerpush(0,0,-3.0,1)
  49.     elseif (weapon_mode==1) then
  50.         -- Disable balloon
  51.         if (attack==1 and weapon_timer<=0) then
  52.             -- Kill by attack
  53.             weapon_mode=0
  54.         elseif collision(cc.balloon.gfx_wpn,getplayerx(0),getplayery(0)-33,1,0)==1 then
  55.             -- Kill by collision
  56.             weapon_mode=0
  57.         elseif getframesleft()<=1 then
  58.             -- Kill by timeout
  59.             weapon_mode=0
  60.         end
  61.         -- Kill? -> FX!
  62.         if weapon_mode==0 then
  63.             particle(p_ring,getplayerx(0),getplayery(0)-33)
  64.             playsound(cc.balloon.sfx_wpn)
  65.         end
  66.         -- Control speed
  67.         playerpush(0,getwind()*10.0,-1.0,1)
  68.     end
  69. end